//
//  Utilities.m
//  We365
//
//  Created by Pham Khuong Duy on 12/16/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "Utilities.h"

@implementation Utilities

- (id)init
{
    self = [super init];
    if (self) {
        // Initialization code here.
    }
    
    return self;
}

+ (int)convertFtoC:(int)F
{
    float result = (float)(F - 32) * 5 / 9;
    return lroundf(result);
}

+ (float)convertKmtoMiles:(float)km
{
    float result = km * 0.621371192f;
    return roundf(result * 2) / 2;
}

+ (NSString *)getFilePath:(NSString *)fileName
{
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    return [documentsDirectory stringByAppendingPathComponent:fileName];
}

+ (BOOL)checkExists:(NSString *)fileName
{
    NSFileManager *fileManager = [NSFileManager defaultManager];
    if(![fileManager fileExistsAtPath:[self getFilePath:fileName]])
        return NO;
    return YES;
}

@end
